<template>
<div class="bgcadmin clearfix">
  <div class="admin-top">
    <div class="w">
       <!-- 左浮动 -->
      <div class="admin-hot">
        <HotLabels></HotLabels>
      </div>
      <!-- 右浮动 -->
      <div class="admin-content">
        <article class="admin">
          <el-tabs v-model="activeName">
            <el-tab-pane label="发表文章" name="first">
              <!-- 发表文章 -->
              <AddArticle></AddArticle>
            </el-tab-pane>
            <el-tab-pane label="文章管理" name="second">
              <!-- 文章管理 -->
              <ArticleManager></ArticleManager>
              </el-tab-pane>
            <el-tab-pane label="添加友链" name="third">
              <!-- 添加友链组件 -->
             <AddLink></AddLink>
              </el-tab-pane>
            <el-tab-pane label="友链管理" name="fourth">
              <!-- 友链管理 -->
             <MangerLink></MangerLink>
              </el-tab-pane>
            <el-tab-pane label="反馈收集" name="fifth">
              <!-- 反馈收集 -->
              <ContactManager></ContactManager>
            </el-tab-pane>
          </el-tabs>
        </article>
      </div>
    </div>
  </div>
</div>
</template>

<script>
// 添加友链
import AddLink from '../components/admin/AddLink.vue';
// 友链管理
import MangerLink from '../components/admin/MangerLink.vue';
// 发表文章
import AddArticle from '../components/admin/AddArticle.vue';
// 文章管理
import ArticleManager from '../components/admin/ArticleManager.vue';
// 反馈收集
import ContactManager from '../components/admin/ContactManager.vue';
import HotLabels from '../components/HotLabels.vue';
export default {
  name: "Admin",
  components:{
    AddLink,
    HotLabels,
    MangerLink,
    AddArticle,
    ArticleManager,
    ContactManager,
  },
  data() {
    return {
      activeName: "third",
    };
  },
  methods: {
    // 验证是否具有管理员权限
    async isCheck(){
      let {data} = await this.$axios({
        method:"POST",
        url:"/administer/isCheck",
      });
      if(data.code){  // 不是管理员
        this.$router.replace("/"); // 跳转到首页
        this.$message.error(data.message);
      }else{
        this.$message.success(data.message);
      }
    }
  },
  created(){  // 组件在创建的时候就触发
    this.isCheck();

  }
};
</script>

<style lang="less" scoped>
.bgcadmin{
  margin-top: 0;
  height: 100%;
  border-top: 1px solid transparent;
  background: url("../assets/images/bgcadmin.jpg") no-repeat;
  background-size: cover;
  background-position: 0px 50%;
}
.admin-top{
  margin-top: 70px;
}
.admin-hot{
  float: left;
  width: 290px;
}
.admin-content{
margin-left: 305px;
}
.admin {
  float: right;
  width: 100%;
  // height: 1500px;
}
/deep/ .el-tabs__nav-wrap{
  background-color: #fff;
  padding-left: 20px;
}
/deep/ .el-tabs__content{
  padding-left: 20px;
  background-color: #fff;
}
/deep/ .el-input{
  width: 400px;
}
</style>